<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue.js"></script>
</head>
<body>
<div id="root">
    <button @click="setUsername">{{username}}</button>
    <p ref="myP">{{age}}</p>
</div>
</body>
<script>
    // 数据发生改变视图会同步立即更新吗？不是
    new Vue({
        el: "#root",
        data:{
            username:"zhangsan",
            age:100
        },
        methods:{
            setUsername(){
                this.username += "!"
                this.age ++;
                // console.log(document.querySelector("button").innerText,this.$refs.myP.innerText)
                // console.log(this);

                // 1- 回调函数
                // this.$nextTick(function(){
                // 	// 视图更新完毕后执行
                // 	console.log(document.querySelector("button").innerText,this.$refs.myP.innerText)
                // })

                // 2- Promise
                this.$nextTick().then(()=>{
                    console.log(document.querySelector("button").innerText,this.$refs.myP.innerText)
                })
            }
        }
    })
</script>
</html>